﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ChoViet.CMS.ViewModels.IndexEventViewModel>" %>
<%@ Import Namespace="ChoViet.Lib.Helpers" %>
<%@ Import Namespace="ChoViet.Lib.Paging" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Quản lý chủ đề
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if(ViewData["MessageInfo"]==null){ %>
	<form action="/Event/IndexCms" method="post" name="adminForm">
		<table width="100%">
			<tr>
			    <td align="left">
			        Tìm nhanh <%= Html.TextBox("Keyword", Model.Keyword) %>
			        <%= Html.ActionImageJS("Tìm kiếm", "icon-32-search.png", "document.adminForm.submit();", false)%>
			    </td>
			</tr>
		</table>
		<table width="100%" class="adminlist">
		    <thead>
			<tr>
				<th width="10" align="right">
					STT
				</th>
				<th width="30">
				</th>
				<th width="30">
				</th>
				<th align ="center">
					<%= Html.Sort("Tên chủ đề", "Title", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th align ="center" width="100px">
					<%= Html.Sort("Ngày tạo", "AddDate", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th align ="center" width="70px">
					<%= Html.Sort("Lượt xem", "nViews", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th align ="center" width="70px">
					<%= Html.Sort("Số bài viết", "nArticle", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th align="center" width="100">
				    Trạng thái KH
				</th>
				<th align ="center">
					<%= Html.Sort("ID", "ID", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
			</tr>
			</thead>
			<tbody>
		<% 
			int i = 0;
    		foreach (var item in Model.Events) {
				i++;
		%>
			<tr id="tr_<%=item.ID%>">
				<td align="right">
					<%= i.ToString() %>
				</td>
				<td align="center">
					<%= Html.ActionImage("Sửa", "icon-24-edit.png", "Event", "EditCms", new Dictionary<string, object>(){{ "id", item.ID }})%>
				</td>
				 <td align="center">
					<img alt="Xóa tag" src="/Images/icon-24-delete.png" onclick="DelEvent(<%=item.ID %>);" />
				</td>
				<td>
				  <%=Html.ActionLink(item.Title, "DetailCms", "Event", new { @id = item.ID }, "")%>
				</td>
				<td align="center" width="100px">
				    <%=Html.Encode(item.AddDate == null ? "" : string.Format("{0:dd/MM/yyyy}", item.AddDate))%>
				</td>
				<td align="center">
				    <%=Html.Encode(item.nViews)%>
				</td>
				<td align="center">
				    <%=Html.Encode(item.nArticle)%>
				</td>
				<td align="center">
                    <img alt="" id="imgPubYN_<%= item.ID %>" value="<%= item.PubYN %>"
                        src="<%= item.PubYN ? "/Images/icon-32-apply.png" : "/Images/icon-32-cancel.png" %>" />
                </td>
				<td align="center" width="50px">
				    <%=Html.Encode(item.ID) %>
				</td>
			</tr>
	    
		<% } %>
        </tbody>
		</table>
		
		<table width="100%">
            <tr>
                <td align="center">
             
                <div class="pager">
                <label>Hiển thị #</label>
                    <%
                        int[] pageSizeList = {1, 5, 10, 15, 20, 25, 50, 100, 500};
                    %>
                    <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.Events.PageSize), new { onchange = "document.adminForm.submit();" })%>

                    <%= Html.Pager(Model.Events.PageSize, Model.Events.PageNumber, Model.Events.TotalItemCount)%>
                </div>
                </td>
            </tr>
        </table>
        <%= Html.Hidden("order")%>
		<%= Html.Hidden("orderDir")%>
	</form>
 <% } %>
 <script type="text/javascript">
     function DelEvent(id) {
         Del(id, 'Event');
     }
 </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
<td>
	<%= Html.Toolbar("Thêm mới", "/Event/CreateCms", "new") %>
 </td>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
Quản lý chủ đề
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
<%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>  
</asp:Content>
